/**
 * Created by zeopean on 2015/10/16.
 */
var page = 1 ;

$(function(){
    /** 初始化ajax */
    jQuery.ajaxSetup({
        case:false,
        headers: {
            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
        }
    });

    $(document).on('click' ,'.more_bar' , function(){
        var stop = true;
        if(stop==true){
            stop=false;

            $.ajax({
                type:"get",
                url:getMore,
                dataType:"json",
                data:{'page':page},
                success:function(obj){
                    setTimeout(function(){
                        if (obj.level == "success") {
                            showMore(obj.data);
                        }
                    },500);
                    stop = true;
                    page = page + 1;
                }
            });
        }
    });

});


function showMore(creaters) {
    var HtmlAll='';
    for (var i = 0; i < creaters.length; i++) {
        if (creaters[i] !== 'undefined') {
            if(!creaters[i].position)
                creaters[i].position            = '' ;
            if(!creaters[i].id)
                creaters[i].id                  = 0  ;
            if(!creaters[i].userInfo.realname)
                creaters[i].userInfo.realname   = '' ;
            if(!creaters[i].userInfo.user_desc)
                creaters[i].userInfo.user_desc  = '' ;
            if(!creaters[i].userInfo.position)
                creaters[i].userInfo.position   = '' ;
            if(!creaters[i].userInfo.province)
                creaters[i].userInfo.province   = '' ;
            if(!creaters[i].userInfo.city)
                creaters[i].userInfo.city       = '' ;

            var HTMLInitData = '<li><dl><dt><a href="'+getDetailById+creaters[i].id+'"><img src="'+showPhoto+creaters[i].id+'" /></a><p>'
            +'</dt><dd class="commpany"><p><a href="#"><strong>'
            +creaters[i].userInfo.realname
            +'</strong></a></p>'
            +creaters[i].userInfo.user_desc
            +'</p></dd><dd class="list"><div class="list_content"><p class="stage"><em class="reveal">角色</em><em class="floatR">'
            +creaters[i].userInfo.position
            +'</em></p><p class="type"><em class="reveal">地区</em><em class="floatR">'
            +creaters[i].userInfo.province+'.'+creaters[i].userInfo.city
            +'</em></p><p class="address"><em class="reveal">最近职位</em><em  class="floatR">'
            +creaters[i].position
            +'</em></p></div></dd></dl></li>';

        }
        HtmlAll += HTMLInitData;
    }
    var onceStr = $(".content ul ").html();
    $(".content ul ").html(onceStr+HtmlAll);
}

function init(){}